package com.baymax.test.scene

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import okhttp3.HttpUrl
import org.json.JSONObject

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun useAppContext() {
        // Context of the app under test.
        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
        assertEquals("com.baymax.test.scene", appContext.packageName)
    }


    @Test
    fun testJson() {
        val json = """
            https://sns.center.bcs.ottcn.com/album/ECommerceNew/CODE/index.html?quickAppAction=detail&actionUrl=http://newams.gsa.bcs.ottcn.com:8081/app/946/com.ysten.wk.shortvideo_117_online.zip&entryPage={"pageType":"secondaryPage","channelGroupId":"10000","programData":{"videoId":"1668505661252","description":"测试足球赛","cover":"http://images.center.bcs.ottcn.com:8080/images/ysten/picture/ndms/dev/2023/12/20/8a6d20502afe4163997d93d6ce6d2896.jpg","uploadTime":"2023-12-19","playUrl":"http://xxx.xxx.xxx.xxx/270000001128/9900000118/index.m3u8?Contentid9%3D900000118&channel-id%3Dnewtv&livemode%3D1","contentType":"LIVE","liveUuid":"","smallImg":"http://images.center.bcs.ottcn.com:8080/images/ysten/picture/ndms/dev/2023/12/20/8a6d20502afe4163997d93d6ce6d2896.jpg","ppvList":[],"timeBucketStart":"1703055046","timeBucketEnd":"1734793989"}}
        """.trimIndent()
        val url = HttpUrl.parse(json)
        val entry = url.queryParameter("entryPage")
        println(entry)
        println(JSONObject(entry))
    }
}